import store from '@/store'
import util from './util'

module.exports.themeClass = (className) => {
	var theme = store.state.theme
	return `ex-mall-${className}${theme ? `--${theme}` : ''}`
}

module.exports.switchTheme = (themeName = '') => {
	store.dispatch('switchTheme', themeName)
	// 存入本地缓存
	util.setStorage('theme', themeName)
}

module.exports.initTheme = () => {
	// 读取本地缓存
	var themeName = util.getStorage('theme') || ''
	store.dispatch('switchTheme', themeName)
}
